# Maintainer: Paul Morgan <jumanjiman@gmail.com>
pkgname=createrepo_c
pkgver=1.1.4
pkgrel=0
pkgdesc="C implementation of createrepo"
url="https://github.com/rpm-software-management/createrepo_c/"
arch="all"
license="GPL-2.0-or-later"
makedepends="
	bash-completion-dev
	bzip2-dev
	cmake
	curl-dev
	expat-dev
	file-dev
	glib-dev
	openssl-dev
	libxml2-dev
	python3-dev
	rpm-dev
	samurai
	sqlite-dev
	xz-dev
	zlib-dev
	zstd-dev
	"
checkdepends="
	check-dev
	py3-nose
	xz
	"
subpackages="
	$pkgname-bash-completion
	$pkgname-dev
	$pkgname-doc
	$pkgname-libs
	py3-$pkgname-pyc
	py3-$pkgname:py3
	"
source="
	$pkgname-$pkgver.tar.gz::https://github.com/rpm-software-management/createrepo_c/archive/$pkgver.tar.gz
	no-bash.patch
	"

build() {
	cmake -B build -G Ninja \
		-DCMAKE_BUILD_TYPE=None \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DCMAKE_SKIP_INSTALL_RPATH=true \
		-DWITH_ZCHUNK=OFF \
		-DWITH_LIBMODULEMD=OFF \
		-DENABLE_DRPM=OFF
	cmake --build build

	if want_check; then
		cmake --build build --target tests
	fi
}

check() {
	cd build
	./tests/run_tests.sh
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	python3 -m compileall -fq "$pkgdir"/usr/lib/python*
}

py3() {
	pkgdesc="Python3 bindings for createrepo_c"

	amove usr/lib/python*
}

sha512sums="
1690a1e8a133a7c0fb1d009444bedb2ee20feb08fc4788174b63e2b133fa89f612a8518ef411fbb6fcefc382575ccb497429702ab230dd10962379c7c604a434  createrepo_c-1.1.4.tar.gz
2511216ef3a3ba85458a7bf6b405be44379597f94e3f377454bc0814d90bb0d1b4f0c1d4707c78a37dc07cbd594911b9f5ac03952ae7bd8a1d9828bea65a6e28  no-bash.patch
"
